import type { IColumnsOption } from 'vc';
import { INDEX, COMPANY_NAME, BUSINESS_DATA, REGISTERED_CAPITAL, PROVINCE, CITY, COUNTRY, INDUSTRY_CATEGORY, INFO_SOURCE, CellRenderMap } from '@/utils/tableColumn';

export function useTable() {
  const columns = ref<IColumnsOption[]>([
    { ...INDEX },
    { ...COMPANY_NAME },
    {
      width: 220,
      title: '证书编号',
      field: 'certificateNumber',
      cellRender: { name: CellRenderMap.HighLight }
    },
    {
      width: 120,
      title: '证书状态',
      field: 'tagEffective',
      sortable: true,
      align:'center',
      slots: {
        default: ({ row }) => {
          const { name, bgColor, color } = row.label;
          return row.label ? (
            <span class="tag-label" style={{ color: color,background: bgColor }}>
              {name}
            </span>
          ) : '-';
        }
      }
    },
    {
      width: 150,
      align: 'center',
      title: '产品类别',
      field: 'productType',
      sortable: true
    },
    {
      width: 150,
      title: '产品名称',
      field: 'productName',
      showOverflow: 'title'
    },
    {
      width: 100,
      title: '发证日期',
      field: 'issuingDate',
      sortable: true
    },
    {
      width: 100,
      title: '到期日期',
      field: 'periodOfValidityExpirationDate',
      sortable: true
    },
    {
      title: '发证机关',
      field: 'licenceIssuingAuthority',
      width: 150,
      showOverflow: 'title',
      sortable: true
    },
    {
      ...INFO_SOURCE('dataSource')
    },
    { ...PROVINCE },
    { ...CITY },
    { ...COUNTRY },
    { ...INDUSTRY_CATEGORY },
    { ...BUSINESS_DATA },
    { ...REGISTERED_CAPITAL }
  ]);

  return {
    columns
  };
}
